
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const ThemePlugin = require('@alifd/next-theme-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const withSass = require('@zeit/next-sass');
const withCss = require('@zeit/next-css');
// fix: prevents error when .css files are required by node
if (typeof require !== 'undefined') {
    require.extensions['.css'] = (file) => {}
}
module.exports = withCss({
    distDir: 'build',
    stats: 'errors-only',
    // useFileSystemPublicRoutes: false,
    webpack:(config,{defaultLoaders}) => {
        config.module.rules.push({
            test: /\.css$/,
            exclude: [path.resolve(__dirname, 'node_modules')],
            use: [
                defaultLoaders.babel,
                {
                    loader: require('styled-jsx/webpack').loader,
                    options: {
                        type: 'scoped'
                    }
                } 
            ]
        })
        
         return config
    }
}) 